home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-04-02 | 5.6 KB | 187 lines | [TEXT/MPS ] |
- { UIconDragging.p}
- { Copyright © 1990, 1991 by Apple Computer, Inc. All rights reserved.}
-
- { Change List:
-
- ddmmyy
- KJS 040391 First version integrated with TangramUI.
- GAP 010491 Formatting changes and comments.
- GAP 010491 Moved declarations for icon dimensions
- and insetsto the implementations.
- GAP 010491 Moved gOffscreenManager global to implementation
- GAP 020491 Moved icon height and width back to interface.
- GAP 020491 Moved USES UOffscreenManager to implementation.
-
- End Change List. }
-
-
- UNIT UIconDragging;
-
- { This unit provides the capability to drag CICNs from one
- view to another across the desktop. }
-
-
- INTERFACE
-
-
- USES
-
- { MacApp }
- UMacApp,
-
- { Other Building Blocks }
- UOSBitmap,
- UOSImage;
-
-
- CONST
-
- cIconTrackerCmd = 9876;
- kIconWidth = 32;
- kIconHeight = 32;
-
-
- TYPE
-
- IconNumber = INTEGER;
-
- IconPlacementSense = (placeIt, unPlaceIt, rePlaceIt);
-
- { TTrackingView is an abstract superclass that records its cicns by their
- resource id number -- the most common way. You will possibly subclass
- from this, or, if your view must be a subclass of some other view class
- (e.g., TGridView), then you will add the methods of this class to your
- subclass. IF only Object Pascal had multiple inheritance ... }
-
- TTrackingView = OBJECT(TView)
-
- FUNCTION TTrackingView.GetInterViewTracker (anIconNumber: IconNumber;
- offset: Point): TInterViewTracker;
-
- PROCEDURE TTrackingView.PlaceIcon (anIconNumber: IconNumber;
- aVPoint: VPoint;
- sense: IconPlacementSense);
-
- END; {TTrackingView}
-
-
-
-
- { TCIconTracker is and abstract superclass that tracks a color icon,
- manipulating offscreen pixmaps to give the visual effects of full
- color dragging. Subclasses' TrackMouse method must call INHERITED
- TrackMouse first. }
-
- TCIconTracker = OBJECT(TCommand)
-
- fFirstTime: BOOLEAN; { First time through tracking loop? }
- fLastTime: BOOLEAN; { Last time through tracking loop? }
- fThisTrackPoint: Point; { The track point this time through the loop - global coord. }
- fLastTrackPoint: Point; { The track point last time through the loop - global coord. }
- fCIcon: CIconHandle; { The icon we're tracking. }
- fScreenLocusRect: Rect; { The area of the screen around the icon. }
- fMaxDepthGrafPort: GrafPtr; { Parent Grafport for fUnderIcon- maximum bit depth. }
- fUnderIcon: TOSImage; { Offscreen Image of the area under the icon. Origin = (0, 0) }
-
- PROCEDURE TCIconTracker.ICIconTracker (itsCmdNumber: CmdNumber;
- itsDocument: TDocument;
- itsView: TView;
- itsScroller: TScroller;
- anIcon: CIconHandle);
-
- PROCEDURE TCIconTracker.Free;
- OVERRIDE;
-
- PROCEDURE TCIconTracker.Fields (PROCEDURE DoToField (fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- { Mouse handling }
- FUNCTION TCIconTracker.TrackMouse (aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand;
- OVERRIDE;
-
- PROCEDURE TCIconTracker.CIconTrack (nextPoint: Point);
-
- END; {TCIconTracker}
-
-
- { TInterViewTracker is an abstract superclass that handles the
- MacApp-isms of moving between views. }
-
- TInterViewTracker = OBJECT(TCIconTracker)
-
- fTrackingWindow : TWindow; { The window we're currently trackign in. Helps performance. }
- fTrackingView: TView; { The view we're currently tracking in. NIL = Desktop. }
- fMouseDownOffset: Point; { Offset of the mouse in relation to the icon. }
- fReleasePoint: VPoint; { The release point of the mouse in fTrackingView's coordinates. }
-
- PROCEDURE TInterViewTracker.IInterViewTracker (aTrackingView: TView; offset: Point);
-
- PROCEDURE TInterViewTracker.Fields (PROCEDURE DoToField (fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- FUNCTION TInterViewTracker.GetCIconHandle: CIconHandle;
-
- { Mouse handling }
- FUNCTION TInterViewTracker.TrackMouse (aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand;
- OVERRIDE;
-
- { Actions }
- PROCEDURE TInterViewTracker.DoIt;
- OVERRIDE;
-
- END; {TInterViewTracker}
-
-
- { TPlaceByNumber is a subclass of TInterViewTracker that records and
- places the tracked icon into a view (in this case a TTrackingView)
- by its resource number. TPlaceByNumber may be overriden to place
- icons, by resource number, in other types of views. Similarly
- designed subclasses of TInterViewTracker could place icons in views
- means other than resource number. }
-
- TPlaceByNumber = OBJECT(TInterViewTracker)
-
- fIconNumber : IconNumber; { The resource id of the cicn being tracked and being placed }
-
- PROCEDURE TPlaceByNumber.IPlaceByNumber (aTrackingView: TView;
- offset: Point;
- anIconNumber: IconNumber);
-
- PROCEDURE TPlaceByNumber.Fields (PROCEDURE DoToField (fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER));
- OVERRIDE;
-
- FUNCTION TPlaceByNumber.GetCIconHandle: CIconHandle;
- OVERRIDE;
-
- { Actions }
- PROCEDURE TPlaceByNumber.DoIt;
- OVERRIDE;
-
- PROCEDURE TPlaceByNumber.UndoIt;
- OVERRIDE;
-
- PROCEDURE TPlaceByNumber.RedoIt;
- OVERRIDE;
-
- END; {TPlaceByNumber}
-
-
- { ::::::::::::::::::::::: Unit Initialization ::::::::::::::::::::::: }
-
-
- PROCEDURE InitUIconDragging; { This init routine sets up gOffScreenManager. }
-
-
- IMPLEMENTATION
-
- {$I $$Shell(SrcApp)UIconDragging.inc1.p}
-
- END. {UNothing}